/<template>
  <div>
      <van-form @submit="onSubmit">
        <van-field
          v-model="username"
          name="name"
          label="用户名"
          placeholder="用户名"
          :rules="[{ required: true, message: '请填写用户名' }]"
        />
        <van-field
          v-model="password"
          type="password"
          name="pwd"
          label="密码"
          placeholder="密码"
          :rules="[{ required: true, message: '请填写密码' }]"
        />
        <van-field
          v-model="role"
          name="role"
          label="角色"
          placeholder="角色"
          :rules="[{ required: true, message: '请输入用户角色' }]"
        />
        <div style="margin: 16px;">
          <van-button round block type="info" native-type="submit">提交</van-button>
        </div>
      </van-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: '',
      password: '',
      role: '',
    };
  },
  mounted() {
    console.log(this.$router)
  },
  methods: {
    onSubmit(values) {
      localStorage.setItem('isLogin', JSON.stringify(values))
      localStorage.setItem('role', values.role)
      this.$router.replace(this.$route.query.fromPath)
    },
  },
}
</script>

<style>

</style>